package cn.edu.scau.dormitory_management_system.module.examine.service.impl;

import cn.edu.scau.dormitory_management_system.module.examine.dao.CheckinAuditDao;
import cn.edu.scau.dormitory_management_system.module.examine.entity.CheckinAuditEntity;
import cn.edu.scau.dormitory_management_system.module.examine.entity.VO.CheckinAuditVO;
import cn.edu.scau.dormitory_management_system.module.examine.service.CheckinAuditService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：Vizzk
 * @description：TODO
 * @date ：2021/8/5 16:59
 */
@Service("checkinAuditService")
public class CheckinAuditServiceImpl extends ServiceImpl<CheckinAuditDao, CheckinAuditEntity> implements CheckinAuditService {

    @Override
    public boolean insertCheckinAudit(CheckinAuditEntity auditEntity) {
        return this.baseMapper.insert(auditEntity)>0;
    }

    @Override
    public List<CheckinAuditEntity> listAuditsByCheckinId(Integer checkinId) {
        QueryWrapper<CheckinAuditEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("checkin_id",checkinId);
        return this.baseMapper.selectList(queryWrapper);
    }

    @Override
    public List<CheckinAuditVO> listAuditVOByCheckinId(Integer checkinId) {
        return this.baseMapper.listAuditVOByCheckinId(checkinId);
    }

    @Override
    public boolean deleteByCheckinId(Integer id) {
        return this.baseMapper.deleteByCheckinId(id);
    }
}
